<?php
/*
 * Created on Jul 24, 2006
 *
 *
 * test20060724.php - kodform4
 * Copyright (C) 2006 boris
 *
 */
 
set_include_path('f:/http/kodform4/lib');
require_once 'Kodform.php';
require_once 'Kodform/Element/Field.php';
require_once 'Kodform/Validator/Regex.php';
require_once 'Kodform/Validator/Size.php';
require_once 'Kodform/Element/Submit.php';
 
$form = new Kodform("login", 0, "");

$fusername =& $form->addElement(new Kodform_Element_Field("username", "Username", Kodform_Element_Field::text, null, "Please enter username"));
$fusername->addValidator(new Kodform_Validator_Regex("'\w*'", "Username can hold only numbers and letters"));
$fusername->addValidator(new Kodform_Validator_Size(10, 4, "Username must be 4 to 10 letters long."));
   	
$fpassword =& $form->addElement(new Kodform_Element_Field("password", "Password", Kodform_Element_Field::password, null, "Please enter password"));
$fpassword->addValidator(new  Kodform_Validator_Regex("'\w*'", "Password can hold only numbers and letters."));
$fpassword->addValidator(new Kodform_Validator_Size(10, 4, "Password must be 4 to 10 letters long."));
    	
$form->addElement(new Kodform_Element_Submit("slogin", "Login"));
?>

<html>
<head>
<title>Kodform Test</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body>
<?php
if($form->isSubmited() && $form->isValid()){
	?>
	<div>You are in. ( Your username: <?php print $form->username->getValue();?>, Your password: <?php print $form->password->getValue();?>)</div>
	<div><a href="">Logout</a></div>
	<?php
}
else
	print $form->display();
     	
?>
</body>
</html>